package com.yx.cloud.activity;

import android.content.Intent;
import android.view.View;

import com.yx.cloud.R;
import com.yx.cloud.base.BaseActivity;
import com.yx.cloud.databinding.ConnectionfailActivityBinding;
import com.yx.cloud.utils.Intent_utils;
import com.yx.cloud.utils.RomUtils;
import com.yx.cloud.utils.SharedPrefsUtil;

/**
 * 配网失败界面
 */
public class ConnectionFailActivity extends BaseActivity implements View.OnClickListener {

    private ConnectionfailActivityBinding binding;

    @Override
    public void onCreate() {
        binding = ConnectionfailActivityBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initData();
    }

    private void initData() {
        binding.ivConnFailedReturn.setOnClickListener(this);
        binding.tvConnectFail.setOnClickListener(this);
        binding.btnConnectFail.setOnClickListener(this);
        binding.btnSwitchNetwork.setOnClickListener(this);
//        if (AppContext.get().getRobotType().equals(X1.get().getConfig().productName) ||
//                AppContext.get().getRobotType().equals(RS11.get().getConfig().productName) ||
//                AppContext.get().getRobotType().equals(RS01.get().getConfig().productName)) {
//            binding.btnSwitchNetwork.setVisibility(View.VISIBLE); //按步骤重试按钮
//        } else {
//            binding.btnSwitchNetwork.setVisibility(View.GONE);
//        }
    }

    @Override
    public void onClick(View v) {
        if (RomUtils.isFastClick()) {
            return;
        }
        switch (v.getId()) {
            case R.id.iv_connFailed_Return:
                Intent_utils.backIntent(this);
                break;
            case R.id.tv_connectFail:
                Intent examinehelp = new Intent(this, ExamineHelpActivity.class);
                startActivity(examinehelp);
                break;
            case R.id.btn_connectFail:
                //按步骤重试
//                Intent selectStep;
//                String value = SharedPrefsUtil.getValue(ConnectionFailActivity.this, "ROBOT_SERIES", "robot_series", "");
//                if (value.equals("bluetooth")) {//Constants.robot_type 是在扫描界面设置的
//                    if (Constants.FLAVOR_INXNI.equals(BuildConfig.FLAVOR)) {
//                        selectStep = new Intent(this, AddEquipmentActivity.class);
//                    } else {
//                        selectStep = new Intent(this, AddEquipmentYinXingActivity.class);
//                    }
//                    selectStep.putExtra("switchNetwork", "switchNetwork");
//                } else {
//                    NetworkConfigParam param = new NetworkConfigParam();
//                    param.setModel(ActivatorModelEnum.TY_EZ);
//
//                    selectStep = new Intent(this, SelectSeriesActivity.class);
//                    selectStep.putExtra("switchNetwork", "fail");
//                }
//                startActivity(selectStep);
//                finish();
                break;
            case R.id.btn_switchNetwork:
                Intent selectseries;
                String value2 = SharedPrefsUtil.getValue(ConnectionFailActivity.this, "ROBOT_SERIES", "robot_series", "");
                if (value2.equals("bluetooth")) {//Constants.robot_type 是在扫描界面设置的
//                    if (Constants.FLAVOR_INXNI.equals(BuildConfig.FLAVOR)) {
//                        selectseries = new Intent(this, AddEquipmentActivity.class);
//                    } else {
//                        selectseries = new Intent(this, AddEquipmentYinXingActivity.class);
//                    }
                    selectseries = new Intent(this, AddEquipmentActivity.class);
                    selectseries.putExtra("switchNetwork", "switchNetwork");
                } else {
//                    NetworkConfigParam param = new NetworkConfigParam();
//                    param.setModel(ActivatorModelEnum.TY_EZ);
                    String mode = SharedPrefsUtil.getValue(this, "EZandAP", "EZandAP", "");
                    if (mode.equals("EZ")) {
                        SharedPrefsUtil.putValue(this, "EZandAP", "EZandAP", "EZ");
                    } else {
                        SharedPrefsUtil.putValue(this, "EZandAP", "EZandAP", "AP");
                    }
                    selectseries = new Intent(this, SelectSeriesActivity.class);
                    selectseries.putExtra("switchNetwork", "fail");
                }
                startActivity(selectseries);
                finish();
                break;
        }
    }

}
